<script src="https://unpkg.com/keras-js@1.0.3"></script>
<body>
<script>

function loadImage(url) {
  return new Promise((resolve, reject) => {
    const img = new Image();
    img.crossOrigin = "anonymous";
    img.src = url;
    img.onload = () => resolve(img);
    img.onerror = reject;
  });
}

async function loadBinaryDataFromUrl(url) {
  const req = new Request(url);
  const res = await fetch(req);
  if (!res.ok) {
    throw Error(res.statusText);
  }
  return res.arrayBuffer();
}

// load and render image data
(async function(){
  
  const url = "data/cat.jpeg";
  const img = await loadImage(url);
  // https://github.com/transcranial/keras-js/blob/master/demos/src/components/models/SqueezenetV1.vue#L39
  // dataTensor = ndarray(new Float32Array(img), [width, height, 4])
}());

// load and render binary data
(async function(){
  
  const size = 100;
  const buf = await loadBinaryDataFromUrl('data/rand.bin');
}());

</script>
</body>